#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import multiprocessing
from multiprocessing import Process
from multiprocessing import Queue


def func(i, q):
    ret = q.get()
    print("进程{0}从队列中获取了一个{1}， 然后又往队列中放了一个 {2}".format(i, ret, i))
    q.put(i)


if __name__ == '__main__':
    q = Queue(10)
    q.put(0)

    for i in range(10):
        p = Process(target=func, args=(i, q))
        p.start()
